package org.example;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

/*
    查寻本地目录
 */
public class demo_3 {
    public static void main(String[] args) throws IOException {
        File file = new File("E://JavaHadoop//upload//");
        FileFilter filefilter = new FileFilter() {

            @Override
            public boolean accept(File file) {
                return file.isDirectory();
            }
        };
        File[] listFiles = file.listFiles(filefilter);
        for (int i = 0; i < listFiles.length; i++) {
            System.out.println(listFiles[i]);
        }
        System.out.println("========");

        File folder = new File("E://JavaHadoop//upload//");
        File[] listOfFiles = folder.listFiles();
        for (int i = 0; i < listOfFiles.length; i++) {
            File file2 = listOfFiles[i];

            if (file2.isFile() && file2.getName().endsWith(".txt")) {
                String content = FileUtils.readFileToString(file2);
                System.out.println(file2);
            }


        }
    }
}